// =============================================================
// CIndexMethods for IST(Index/Search Tool)
// ---------------------------------------
// Author : Woo-Hyun Kim
// Email : woorung@icu.ac.kr or woorung@nhncorp.com
// Date : Aug. 8, 2006
// =============================================================
#ifndef CIndexMethodsH
#define CIndexMethodsH
//-----------------------------------------------------------------
#include <iostream>
#include <iterator>
#include <vector>
#include <list>
#include <map>
#include <algorithm>
#include <fstream>
#include <string>

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <sys/stat.h>
#include <dirent.h>

#include "CMethod.h"
#include "CFileManager.h"
#include "CSmartString.h"
#include "CDocument.h"

using namespace std;
//-----------------------------------------------------------------
class CIndexMethods : public CMethod {
public :
	CIndexMethods(string &name);
	~CIndexMethods();

	void run();

	// common functions
	string &getExportedLibsCommand(map<string,string> &parameters, string &command);
	string &executeShellCommand(string &command);
	void inspectParameters(string &name, map<string,string> &parameters);
	void generateDirectory(string &default_path, string &current_path);
	void removeDirectory(string &target_path);
	void executeSigmaDocumentLocation(map<string,string> &parameters);
	void executeSigmaIndex(map<string,string> &parameters);
	void executeSigmaFilter(map<string,string> &parameters);
	void deliverByRSYNC(string &name, map<string,string> &parameters);
	void startNXPFromConfFiles(map<string,string> &parameters);
	void startNXP(map<string,string> &parameters);
	void stopNXPFromConfFiles(map<string,string> &parameters);
	void stopNXP(map<string,string> &parameters);

	// these methods must be overridden in subclasses
	void initializeEnvironment(string &name, map<string,string> &parameters);
	void fetchByRSYNC(string &name, map<string,string> &parameters);
	void dispatchByRSYNC(string &name, map<string,string> &parameters);
	void makeupCommonIndexBlock(string &name, map<string,string> &parameters);
	void makeupIndexBlock(string &name, map<string,string> &parameters);
	void index(string &name, map<string,string> &parameters);
	void makeupNXP(string &name, map<string,string> &parameters);
	void nxp(string &name, map<string,string> &parameters);
};
//----------------------------------------------------------------
#endif
